var path = require('path');
var routeComponentRegex = /component\/([^\/]+\/?[^\/]+).js$/;
module.exports = {
    entry: {
        app: path.resolve(__dirname, 'app/public/main.js')
    },
    output: {
        path: path.resolve(__dirname, 'build'),
        filename: 'bundle.js',
        chunkFilename: 'app/[name].[chunkhash:5].chunk.js'
    },
    module: {
        loaders: [{
            test: /\.js$/,
            exclude: /node_modules/,
            loader: 'babel',//在webpack的module部分的loaders里进行配置即可
        }, {
            test: /\.css$/,
            loader: 'style!css'
        }, {
            test: /\.scss$/,
            loader: 'style!css?modules&importLoaders=2&sourceMap&localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap'
        }, {
            test: /\.(png|jpg)$/,
            loader: 'url?limit=25000'
        }, {
            test: /\.woff$/,
            loader: 'url?limit=100000'
        }, {
            test: /\.js$/,
            include: path.resolve(__dirname, 'src'),
            exclude: routeComponentRegex,
            loader: 'babel'
        }, {
            test: routeComponentRegex,
            include: path.resolve(__dirname, 'src'),
            loaders: ['bundle?lazy', 'babel']
        }]
    },
    devServer: {
        colors: true,//终端中输出结果为彩色
        inline: true,//实时刷新
        // host: 'localhost',
        host: 'localhost',
        port: 8080
    }
};